/*
 * =====================================================================================
 *
 *       Filename:  str_to_mac.c
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2020年01月14日 12时17分07秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *   Organization:  
 *
 * =====================================================================================
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdint.h>

int main()
{
    const char *mac_str = "11:22:33:aa:bb:cc";
    uint8_t mac[6] = {0};
    int ret = sscanf(mac_str, "%02x:%02x:%02x:%02x:%02x:%02x",
            &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
    if(ret != 6) {
        perror("sscanf()");
    }
    printf("ret=%d, %2X:%02X:%02X:%02X:%02X:%02X\n",
            ret, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
    return 0;
}


